#include "ros/ros.h"
#include "std_msgs/String.h"
#include "std_msgs/Int32MultiArray.h"
#include <sstream>
#include "data_type_define.hpp"
#include "main_while.hpp"
 Wheel_in_out_module *wm;
void Control_Callback(const std_msgs::Int32MultiArray::ConstPtr& msg)
{
 // ROS_INFO("I heard: [%s]", msg->data.c_str());
// ROS_INFO("I heard control : %d ",msg->data[0]);
size_t size;
std::vector<std::int32_t> data_temp;
data_temp.resize(40,0);
size=msg->data.size();
for(int i=0;i<size;i++)data_temp[i]=msg->data[i];
wm->node_topic_callback(data_temp);
}

int main(int argc, char **argv)
{

  ros::init(argc, argv, "e_wheel");
  ros::NodeHandle n;
  
   ros::Publisher chatter_pub = n.advertise<std_msgs::Int32MultiArray>("e_wheel_info", 10);

  ros::Rate loop_rate(100);

  int count = 0;
  auto message = std_msgs::Int32MultiArray();
  message.data.resize(40);
  message.data[0]=0;
  ros::Subscriber sub = n.subscribe("e_wheel_ctr", 10, Control_Callback);
  wm= new Wheel_in_out_module();
  while (ros::ok())
  {
    std_msgs::String msg;
    std::stringstream ss;
 
    // ss << "helsdsdsdsdlo world " << count;
    // msg.data = ss.str();
    // ROS_INFO("%s", msg.data.c_str());
    ROS_INFO("this run0");
    wm->node_time_callback( message.data);
    
    chatter_pub.publish(message);
    ros::spinOnce();
    loop_rate.sleep();
    ++count;
  }
  return 0;
}